import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/ant-design-vue.js'

import {mavonEditor} from "mavon-editor";
import "mavon-editor/dist/css/index.css";

Vue.component("mavon-editor", mavonEditor);

Vue.config.productionTip = false

axios.defaults.baseURL = 'http://daman.tpddns.cn:99'
axios.defaults.withCredentials = true

router.beforeEach((to, from, next) => {
  axios.get('/user/getUser').then(function (resp) {
    let user;
    user = resp.data;
    if (user==''){
      location.href = 'https://jxjlife.cn';
    }
    if (to.matched[0].path=='/admin'){
      if (user.type!=-1 && user.type!=0)
        location.href = 'https://jxjlife.cn';
    }
  })
  if (to.name){
    document.title = to.name;
  }
  scrollTo(0,0);
  next();
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
